import 'package:flutter/material.dart';

class ListViewWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListViewDemo3Widget();
  }
}

class ListViewDemo3Widget extends StatelessWidget {
  const ListViewDemo3Widget({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.separated(itemBuilder: (BuildContext bctx, int index) {
      return Text("item$index");
    }, separatorBuilder: (BuildContext bctx, int index) {
      return Divider(color: Colors.black,
        thickness: 1,
        indent: 10,
        endIndent: 10,
        height: 10, //分割线占有的高度空间，不是具体粗细
      );
    }, itemCount: 100);
  }
}

class ListViewDemo2Widget extends StatelessWidget {
  const ListViewDemo2Widget({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: 80,
        itemExtent: 50,
        itemBuilder: (BuildContext bctx, int index) {
          return ListTile(
            leading: Icon(Icons.people),
            trailing: Icon(Icons.add),
            title: Text("联系人$index"),
            subtitle: Text("手机号码13560000000"),
          );
        });
  }
}

class ListViewDemo1Widget extends StatelessWidget {
  const ListViewDemo1Widget({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView(
      scrollDirection: Axis.vertical, //默认就是垂直方向的
      itemExtent: 60, //每个item都统一高度，不设置item高度包裹内容可能不一致
      children: List.generate(100, (index) {
        return ListTile(
          leading: Icon(Icons.people),
          trailing: Icon(Icons.delete),
          title: Text("联系人$index"),
          subtitle: Text("手机号码13560000000"),
        );
      }),
    );
  }
}
